package com.auxgroup.hr.front.site.co.process;

import javax.annotation.Resource;

import com.auxgroup.hr.front.site.co.BaseWfCO;
import com.auxgroup.hr.front.site.inteceptor.SessionGain;
import com.auxgroup.hr.front.site.vo.process.WfPhfHdrRespVO;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.auxgroup.hr.front.commons.BaseRetCode;
import com.auxgroup.hr.front.commons.vo.BaseResponseVO;
import com.auxgroup.hr.front.commons.vo.UserDTO;
import com.auxgroup.hr.front.dao.domain.PsCAppStepInst;
import com.auxgroup.hr.front.dao.domain.PsCWfPhfHdr;
import com.auxgroup.hr.front.dozer.IObjectMapper;
import com.auxgroup.hr.front.service.process.ProcessService;
import com.auxgroup.hr.front.service.process.WfFileService;
import com.auxgroup.hr.front.service.process.WfPhfHdrService;
import com.auxgroup.hr.front.site.co.BaseCO;
import com.auxgroup.hr.front.site.inteceptor.SessionGain;
import com.auxgroup.hr.front.site.vo.process.WfPhfHdrRespVO;

import java.util.Set;

/**
 * 社保公积金异地缴纳审批
 * @author lv-PC
 *
 */
@RestController
@RequestMapping("${auxgroup.hr.contextPath}/wfPhfHdr")
public class WfPhfHdrCO extends BaseWfCO {

	private static final Logger logger = LoggerFactory.getLogger(WfPhfHdrCO.class);

	@Autowired
	private WfPhfHdrService wfPhfHdrService;

	
	@Resource(name = "dozerMapper")
	protected IObjectMapper objectMapper;
	
	/**
	 * 获取社保公积金异地缴纳审批信息
	 * @param hireId
	 * @return
	 */
	@GetMapping(value = "/getPhfInfo")
	public BaseResponseVO getOne(String cTransactionNbr,@SessionGain("user") UserDTO user) {
		logger.info("getWfDrftHdr param= {}", cTransactionNbr);
		if(StringUtils.isBlank(cTransactionNbr)){
			return buildRespone(BaseRetCode.CODE_ERROR_REQUEST_PARAM_NULL);
		}
		PsCWfPhfHdr phfHdr = wfPhfHdrService.getWfPhfHdr(cTransactionNbr);
		if(phfHdr==null){
			return buildRespone(BaseRetCode.CODE_ERROR_PROCESS_NOT_EXIST);
		}
		WfPhfHdrRespVO respVo = objectMapper.map(phfHdr, WfPhfHdrRespVO.class,"notCopyNull_phf");
		//构建社保公积金/个税
		StringBuilder socialDesc = new StringBuilder();
		if(StringUtils.isNotBlank(phfHdr.getcYesNo1())&&"Y".equals(phfHdr.getcYesNo1())){
			socialDesc.append("社保公积金");
		}
		if(StringUtils.isNotBlank(phfHdr.getcYesNo2())&&"Y".equals(phfHdr.getcYesNo2())){
			if(socialDesc.length()>0){
				socialDesc.append("/");
			}
			socialDesc.append("个税");
		}
		respVo.setSocialDesc(socialDesc.toString());
		fillBaseWfInfo(user, phfHdr, respVo);
		return buildRespone(respVo);
	}

	@Override
	protected Set<String> getAuthFileds() {
		return null;
	}
}
